package com.mojian.controller.site;

import java.util.List;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import com.mojian.entity.SysAccessLog;
import com.mojian.service.SysAccessLogService;
import com.mojian.common.Result;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.RequiredArgsConstructor;

/**
 * 访问日志 控制器
 */
@RestController
@RequestMapping("/sys/sysAccessLog")
@RequiredArgsConstructor
@Api(tags = "访问日志管理")
public class SysAccessLogController {

    private final SysAccessLogService sysAccessLogService;

    @GetMapping("/list")
    @ApiOperation(value = "获取访问日志列表")
    public Result<IPage<SysAccessLog>> list(SysAccessLog sysAccessLog) {
        return Result.success(sysAccessLogService.selectPage(sysAccessLog));
    }

    @GetMapping("/{id}")
    @ApiOperation(value = "获取访问日志详情")
    public Result<SysAccessLog> getInfo(@PathVariable("id") Long id) {
        return Result.success(sysAccessLogService.getById(id));
    }

    @PostMapping("/add")
    @ApiOperation(value = "添加访问日志")
    public Result<Object> add(@RequestBody SysAccessLog sysAccessLog) {
        return Result.success(sysAccessLogService.insert(sysAccessLog));
    }

    @PutMapping("/update")
    @ApiOperation(value = "修改访问日志")
    public Result<Object> edit(@RequestBody SysAccessLog sysAccessLog) {
        return Result.success(sysAccessLogService.update(sysAccessLog));
    }

    @DeleteMapping("/delete/{ids}")
    @ApiOperation(value = "删除访问日志")
    public Result<Object> remove(@PathVariable List<Long> ids) {
        return Result.success(sysAccessLogService.deleteByIds(ids));
    }
}
